 ///
 /// @file    sub.cc
 /// @author  lemon(haohb13@gmail.com)
 /// @date    2016-03-15 10:22:50
 ///
 
#include <iostream>
using std::cout;
using std::endl;

class Base
{
public://两个虚函数，如果作为虚函数，并没有形成覆盖
	virtual int func(int x)
	{
		cout << "Base::func(int)" << endl;
		return x;
	}

};

class Sub : public Base
{
public:
	virtual int func(float x)
	{
		cout << "Sub::func(float)" << endl;
		float y = x;
		return y;
	}
};

void test(Base & rhs)
{
	cout << "x = " << rhs.func(5) << endl;
}

int main(void)
{
	Base base;
	Sub sub;

	//test(base);
	//test(sub);

	sub.func(5);//隐藏了基类的func函数

	Base & refbase = sub;
	refbase.func(5);

	return 0;

}
